#ifndef DEALMESSAGE_H
#define DEALMESSAGE_H


#include "MessageTran.h"
#include "structinterface.h"
#include "readermethod_global.h"
#include <list>


#define MAX_BUFFER_SIZE         128*1024

//using namespace ReaderSetting;
struct READERMETHODSHARED_EXPORT BackMessageData{
    unsigned char   type;
    unsigned char   operaterSuccess;
    int             msgLen;
    unsigned char   msgStr[256];
};

class DealMessage //: public QMainWindow
{
   // Q_OBJECT

public:
    //explicit DealMessage(QWidget *parent = 0);
    DealMessage();
    ~DealMessage();

    int DecodeThenDealMessage(int nrecvLen, unsigned char buf[], list<string> &ls_msg);
    BackMessageData DealMsg(unsigned char *msg, int nLen);

    void ProcessSetProfile(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetProfile(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetUartBaudrate(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetFirmwareVersion(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetReadAddress(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetWorkAntenna(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetWorkAntenna(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetOutputPower(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetOutputPower(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetFrequencyRegion(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetFrequencyRegion(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetBeeperMode(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetReaderTemperature(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetDrmMode(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetDrmMode(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetImpedanceMatch(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessReadGpioValue(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessWriteGpioValue(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetAntDetector(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetAntDetector(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetReaderIdentifier(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetReaderIdentifier(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessInventory(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessReadTag(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessWriteTag(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessLockTag(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessKillTag(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessSetAccessEpcMatch(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetAccessEpcMatch(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessRealInventory( unsigned char* msg, int nLen, BackMessageData &msgData );
    void ProcessCustomSessionInventory( unsigned char *msg, int nLen, BackMessageData &msgData );
    void ProcessFastSwitch( unsigned char* msg, int nLen, BackMessageData &msgData );
    void ProcessSetMonzaStatus( unsigned char* msg, int nLen, BackMessageData &msgData );
    void ProcessGetMonzaStatus(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetInventoryBuffer(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetAndResetInventoryBuffer(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessGetInventoryBufferTagCount(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessResetInventoryBuffer(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessInventoryISO18000(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessReadTagISO18000(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessWriteTagISO18000(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessLockTagISO18000(unsigned char* msg, int nLen, BackMessageData &msgData);
    void ProcessQueryISO18000(unsigned char* msg, int nLen, BackMessageData &msgData);

    string GetErrorStr(unsigned char errorCode);
/*
//自定义信号
signals:
    void Signal_ShowFirewareVersion(char* version, int len);
    void Signal_ShowReaderTemp(char* temp, int len);
    void Signal_ShowReaderIdentifier(QString str);
    void Signal_ShowOutputPower(int outputPower);
    void Signal_DrmModeGet(unsigned char drmMode);
    void Signal_ShowInventoryData(InventoryData inventoryData);
    void Signal_ShowReadTagData(TagReadBack tagData);
    void Signal_ShowEpcBuffer(EpcData epcData);
    void Signal_ShowFastInventoryData(int labelTime, int time);
   // void Signal_ShowReadTagData(ReadTagData tagData);
    void Signal_ShowFastEpcBuffer(EpcData epcData);
    void Signal_StopInventory();
    void Signal_ReadWorkAnt(unsigned char workAnt);
    void Signal_GetAntDetector(unsigned char antState);
    void Signal_ReturnLoss(unsigned char returnLoss);
    void Signal_FreqRegion(FreqRegionDefault freq);
    void Signal_FreqRegionCustom(FreqRegionCustom custom, int startFreq);
    void Signal_RfLinkProfile(unsigned char profileID);
    void Signal_GetAccessEpc(unsigned char* epc, int epcLen);
    void Signal_ReadGPIO(unsigned char gpio1, unsigned char gpio2);

    void Signal_ShowTxtLog(string strLog);
*/

public:
    //处理是否完成
    bool m_dealIsOver;

private:
    //接收信息存储
    unsigned char m_RecvBuffer[MAX_RECV_SOCKET_BUFFER];
    unsigned int  m_CurrentBufferIndex;

    MessageTran* m_msgTran;
    bool m_Continue;
    //CommArg      m_commArg;
    
    unsigned char m_workAntId; //此次盘存所用的天线号
    short         m_tagCount;  //识别标签的总数量
    short         m_readRate;  //此次执行命令的标签识别速度，不区分是否多次读取同一张标签
    int           m_totalRead; //此次执行命令的标签的总读取标签次数，不区分是否多次读取同一张标签

    InventoryCount inventoryData;

    //ErrorMethod     m_errorMethod; //错误信息

};

#endif // DEALMESSAGE_H
